﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using GameObjectsAndEquipment.Weapons;

namespace GameObjectsAndEquipment
{
    public class VampireRider : CollidableObject
    {
        private List<Bullet> bulletsShot;
        private List<ObjectPowerUp> powerups;
        private Equipment equipment;
        private int hp = 20;
        private float speed = 90f;
        public float minSpeed = 90f;

        public List<Bullet> BulletsShot
        {
            get { return bulletsShot; }
        }

        public Equipment Equipment
        {
            get { return equipment; }
            set { equipment = value; }
        }

        public int Hp
        {
            get { return hp; }
            set { hp = value; }
        }

        public float Speed
        {
            get { return speed; }
            set { speed = value; }
        }

        public List<ObjectPowerUp> Powerups
        {
            get { return powerups; }
            set { powerups = value; }
        }

        public VampireRider(Vector2 position, Texture2D texture)
            :base(position, texture)
        {
            bulletsShot = new List<Bullet>();
            equipment = new Equipment();
            powerups = new List<ObjectPowerUp>();
        }

        public override void Update(GameTime gametime)
        {
            base.Update(gametime);

            equipment.Weapon.Update(gametime);

            for (int i = powerups.Count-1; i >= 0 ; i--)
            {
                powerups[i].Update(gametime);
                if (powerups[i].isUsedUp)
                {
                    speed = minSpeed;
                    powerups.RemoveAt(i);
                }
            }
  
        }

        public void Shoot(Vector2 destinationPoint)
        {
            equipment.Weapon.Shoot(destinationPoint, true);
        }

        public void Hit(int dmg)
        {
            hp -= dmg;
            if (hp < 0)
            {
                hp = 0;
            }
        }

        public void Heal(int points)
        {
            hp += points;
        }
    }
}
